#include "Generate_C_std.h"
#include "Pattern_assign_var.h"

/* $x = $$y;
 *		or
 *	$x =& $$y;
 *
 * Semantics:
 *		The same as $x = $z; except $z is named at run-time by $y.
 *		Additionally, there is a conversion to strings needed:
 *			TODO
 */
class Pattern_assign_expr_var_var : public Pattern_assign_var
{
public:
	Expr* rhs_pattern()
	{
		rhs = new Wildcard<Variable_variable>;
		return rhs;
	}

	void generate_code (Generate_C* gen)
	{
		VARIABLE_NAME* lhs_var = lhs->value;
		VARIABLE_NAME* index_var = rhs->value->variable_name;

		if (!agn->is_ref)
			INST (buf, "assign_expr_var_var", lhs_var, index_var);
		else
			INST (buf, "assign_expr_ref_var_var", lhs_var, index_var);
	}

protected:
	Wildcard<Variable_variable>* rhs;
};


CREATE(Pattern_assign_expr_var_var);
